class Player(object):
    numbers = 0  # 类属性 （不属于单个实例）
    levels = ['青铜', '白银', '黄金', '钻石', '王者']

    def __init__(self, name, age, city, level):  # 初始化函数（构造函数
        self.name = name
        self.age = age
        self.city = city
        self.level = level
        Player.numbers += 1  # 统计玩家人数
        if level not in Player.levels:
            raise Exception("段位设置错误！")

    def level_up(self):
        i = Player.levels.index(self.level)
        if i < len(Player.levels) - 1:
            self.level = Player.levels[i + 1]
            print("已升级，当前等级为", self.level)
        else:
            print("您的等级已是最高级,无法升级")

    def show(self):  # 实例的方法
        print('我是王者游戏的第%d个玩家，我的名字是%s,我来自%s' % (Player.numbers, self.name, self.city))

    def get_weapon(self, weapon):
        self.weapon = weapon

    def show_weapon(self):
        return self.weapon.show_weapon()

    # 类方法
    @classmethod
    def get_players(cls):  # 类方法
        print("玩家数量到达了%d人" % cls.numbers)

    @staticmethod
    def isValid(**kwargs):
        if kwargs['age'] > 18:
            return True
        else:
            return False


tom = Player('tom', 18, '苏州', '黄金')
tom.get_players()

info = {"name": 'jack', "age": 10}
if not Player.isValid(**info) :
    print("未成年人不得玩游戏")


class weapon(object):
    numbers = 0  # 武器数
    max_damage = 10000
    levels = ['青铜', '白银', '黄金', '钻石', '王者']
    all_weapons = []  # 保存错油武器

    def __init__(self, name, damage, level):
        self.name = name
        self.damage = damage
        self.level = level
        weapon.numbers += 1
        if damage > weapon.max_damage:
            raise Exception("你设置的伤害值已超出最大值")
        if level not in weapon.levels:
            raise Exception("段位设置错误！")
        weapon.all_weapons.append(self)

    def show_weapon(self):
        for k, v in self.__dict__.items():
            print(k, v)

    @classmethod
    def get_max_damage(cls):
        max = 0
        for i in weapon.all_weapons:
            print(i.damage)
            if max < i.damage:
                max = i.damage
        print("武器伤害最大值：", max)


gun = weapon('magic', 10000, '王者')
arrow = weapon('arrow', 450, '青铜')
gun.get_max_damage()
